<!DOCTYPE>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
        <title></title>
		<link rel="stylesheet" href="__PUBLIC__/doExercise/css/jqmobo.css">
		<link rel="stylesheet" href="__PUBLIC__/doExercise/css/collect.css">
        <script src="__PUBLIC__/js/collect.js"></script>
        <script src="__PUBLIC__/doExercise/js/jquery.min.js"></script>
		<script type="text/javascript">
			k = "0";
			var enterTime = "{$enterTime}";
        </script>
    </head>
	<body>
		<form id="form1" method="post" action="">
			<div id="toptitle">
                <h1 class="htitle">错题回顾</h1>
            </div>
			<div id="divContent">
				<fieldset class="fieldset" style="" id="fieldset1">
					<div class="field ui-field-contain" id="div1" req="1" topic="1" data-role="fieldcontain" type="3">
						<div class="field-label">
							{$wrongId}、
                            <label style="float: right;">错题数量：<span id="wrongNum">{$wrongNum}</span></label>
							<img src="http://testet-public.stor.sinaapp.com{$item.questionPicPath|str_replace='/Public','',###}{$item.questionPicName}" alt="">				
                        </div>
						<div class="ui-controlgroup">
							<div class="ui-radio" id="choiceA" onclick="k = '对';"><span class="jqradiowrapper"><a class="jqradio" href="javascript:;"></a></span>
                                <label for="q1_1">对<span id="opA"></span></label>
                            </div>
							<div class="ui-radio" id="choiceB" onclick="k = '错';"><span class="jqradiowrapper"><a class="jqradio" href="javascript:;"></a></span>
                                <label for="q1_1">错<span id="opB"></span></label>
                            </div>

                        </div>
						<div id="answerAera" name="answerAera">
                        </div>
						<div id="explainAera" name="explainAera">
                        </div>
                    </div>
                </fieldset>
            </div>
			
			<div class="footer" id="footer">
				<div id="divSubmit1" style="padding: 10px; margin-top: -15px;">
                    <a id="ctlNext1" class="button blue" href="#answerAera">提交 </a>
                </div>
            </div>
            <div style="margin-top:10px"></div>

<!-- 			<div id="divSubmit4" style="padding: 10px; margin-top: -15px;display:none;" >
<a class="button black" href="{:U('Random/comment')}/questionItem/{$itemid}">评论</a>
</div>
			
				<div id="divSubmit" style="padding: 10px; margin-top: -15px;">
<a id="ctlNext1" class="button yellow" href="#collectArea">收藏</a>
</div>
			<div id="main" class="main">
				<div id="divSubmit2" class="zan" style="padding: 10px; margin-top: -15px;">
<a id="ctlNext2" class="button yellow" href="#collectAera">收藏</a>
</div>
			</div> -->

				<div id="divSubmit" style="padding: 10px; margin-top: -15px;">
                    <a class="button white" href="{:U('Review/review')}">下一题</a>
            </div>


			<!-- <include file="{:U('commentArea')}?questionItem={$itemid}"> -->
			<!-- <a class="butto white" href="{:U('Random/commentArea')}/questionItem={$itemid}">评论</a> -->
            <div style="height:40px"></div>
        </form>


		<script type="text/javascript">
			//用于控制选择后的效果
			$(".ui-radio").click(function(event) {
				$(".focuschoice").toggleClass('focuschoice');
				$(".jqchecked").toggleClass('jqchecked');
				$(this).toggleClass('focuschoice');
				$(this).find('.jqradio').toggleClass('jqchecked');
			});
			$("#divSubmit1").click(function(e){
				if (k == 0) {
					alert('你还没有选择答案！');
					return false;
                }
				//接下来往数据库发送数据
				var ajaxData = {};
				ajaxData['kk'] = "{$kk}"; // 用来解决一个特别难解决的位置问题
				ajaxData['openId'] = "{$openId}"; //用户id	
				ajaxData['itemId'] = "{$itemId}"; //题目的id
				ajaxData['enterTime'] = "{$enterTime}";
				ajaxData['answer'] = k; //用户选择的答案
				ajaxData['lefeTime'] = "setInServer";
				$.ajax({
					cache: false,
					type: "POST",
					url: "{:U('Review/getRightAns')}",
					dataType: "json",
					data: ajaxData,
					// timeout: 30000,
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						return false;
					},
					success: function(jsApiParameters) {
						//alert("success");
						if (jsApiParameters == '非法的请求方式' || typeof(jsApiParameters) == "undefined") {
							alert("网络问题，请稍后答题！");
							return false;
                        }
						var rightAnswer = jsApiParameters['rightAnswer'];
						var analysisPicPath = jsApiParameters['analysisPicPath'];
						var analysisPicName = jsApiParameters['analysisPicName'];
						var opANum = jsApiParameters['opANum'];
						var opBNum = jsApiParameters['opBNum'];
						var opCNum = jsApiParameters['opCNum'];
						var opDNum = jsApiParameters['opDNum'];
						var opAllNum = jsApiParameters['opAllNum'];
						document.getElementById('answerAera').innerHTML = "标准答案：" + rightAnswer;					
						!analysisPicPath ? "" : document.getElementById('explainAera').innerHTML = "<img src=http://testet-public.stor.sinaapp.com" + analysisPicPath.slice(7) + analysisPicName + ">";
						$('#footer').hide();
						$('#divSubmit4').show();
						$('#main').show();//控制收藏按钮出现

						/*============ show option ==============*/
						// document.getElementById('opA').innerHTML = "<progress value='" + opANum + "' max='" + opAllNum + "' class='piao'></progress>" + opANum + "人";
						// document.getElementById('opB').innerHTML = "<progress value='" + opBNum + "' max='" + opAllNum + "' class='piao'></progress>" + opBNum + "人";
						// document.getElementById('opC').innerHTML = "<progress value='" + opCNum + "' max='" + opAllNum + "' class='piao'></progress>" + opCNum + "人";
						// document.getElementById('opD').innerHTML = "<progress value='" + opDNum + "' max='" + opAllNum + "' class='piao'></progress>" + opDNum + "人";

						/*============== show answer record ========*/
						// var rightAnswerNum = rightAnswer == k ? {$answerRecord.answerRightNum} + 1 : {$answerRecord.answerRightNum};
						// document.getElementById('answerRightNum').innerHTML = rightAnswerNum;
						// document.getElementById('answerNum').innerHTML = {$answerRecord.answerNum} + 1;
                    }
				});
			});
			$("#divSubmit2").click(function(e){

				var ajaxData = {};
				ajaxData['openId'] = "{$openId}"; //用户id	
				ajaxData['itemId'] = "{$itemId}"; //题目的id
				ajaxData['enterTime'] = "{$enterTime}";
				ajaxData['answer'] = k; //用户选择的答案
				ajaxData['lefeTime'] = "setInServer";
				//ajaxData['collect'] = 1;//是否收藏
				$.ajax({
					cache: false,
					type: "POST",
					url: "{:U('Review/collect')}",
					dataType: "json",
					data: ajaxData,

				});
			});
        </script>
		<script>
        </script>
    </body>

</html>